using System;
using RpgXna.Model.Interfaces;
using RpgXna.Model.XnaClassesWrappers;

namespace RpgXna.Model.Menu.MenuBehaviors
{
    class MenuShowHideBehavior : KeysInputBehavior
    {
        private readonly Action _action;

        public MenuShowHideBehavior(Func<bool> predicate, Action action)
        {
            _action = action;
            Predicate = predicate;
        }

        public void Execute(IKeyboardStateWrapper kbs)
        {
            if (!Predicate()) return;
            CurKbs = kbs;

            if (KeyPressed(InputBindings.Bindings.Menu))
            {
                _action();
            }

            Prevkbs = kbs;
        }
    }
}